﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
   public class DanhMucNguoiDung
    {

        AccessData ac = new AccessData(1);
        public int sua(string manv, string tennv, int douutien, string mapb, string duongdan, int chucvu,int userid)
        {
            SqlParameter[] arrPara = new SqlParameter[8];
            arrPara[0] = new SqlParameter("@MaNV", SqlDbType.NVarChar);
            arrPara[0].Value = manv;
            arrPara[1] = new SqlParameter("@TenNV", SqlDbType.NVarChar);
            arrPara[1].Value = tennv;
            arrPara[2] = new SqlParameter("@DoUuTien", SqlDbType.Int);
            arrPara[2].Value = douutien;
            arrPara[3] = new SqlParameter("@MaPB", SqlDbType.VarChar);
            arrPara[3].Value = mapb;
            arrPara[4] = new SqlParameter("@ChuKy", SqlDbType.Image);
            arrPara[4].Value = ClassXuLyChung.ConvertImageToByte(duongdan);
            arrPara[5] = new SqlParameter("@MaChucVu", SqlDbType.Int);
            arrPara[5].Value = chucvu;
            arrPara[6] = new SqlParameter("@UserID", SqlDbType.Int);
            arrPara[6].Value = userid;
            arrPara[7] = new SqlParameter("@DuongDan", SqlDbType.NVarChar);
            arrPara[7].Value = duongdan;
          
            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtsuanguoidung", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int them(string manv,string tennv,int douutien,string mapb,string duongdan,int chucvu)
        {
            SqlParameter[] arrPara = new SqlParameter[6];
            arrPara[0] = new SqlParameter("@MaNV", SqlDbType.NVarChar);
            arrPara[0].Value = manv;
            arrPara[1] = new SqlParameter("@TenNV", SqlDbType.NVarChar);
            arrPara[1].Value = tennv;
            arrPara[2] = new SqlParameter("@DoUuTien", SqlDbType.Int);
            arrPara[2].Value = douutien;
            arrPara[3] = new SqlParameter("@MaPB", SqlDbType.VarChar);
            arrPara[3].Value = mapb;
            arrPara[4] = new SqlParameter("@ChuKy", SqlDbType.Image);
            arrPara[4].Value = ClassXuLyChung.ConvertImageToByte(duongdan);
            arrPara[5] = new SqlParameter("@MaChucVu", SqlDbType.Int);
            arrPara[5].Value = chucvu;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtthemnguoidung", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoa(int userid)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@ID", SqlDbType.Int);
            arrPara[0].Value = userid;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_qtxoanguoidung", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loaddulieubyid(int userid)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
            arrPara[0].Value = userid;

            return ac.ftblDocDuLieuSP("thuan_qtloaddanhsachnguoidungbyid", arrPara);

        }
        public DataTable loadgrid()
        {
            return ac.ftblDocDuLieuSP("thuan_qtloaddanhsachnguoidung", null);
        }
        public DataTable loadcombodouutien()
        {
            return ac.ftblDocDuLieuSP("thuan_qtdanhmucnguoidungloadcombodouutien", null);
        }
        public DataTable loadcombochucvu()
        {
            return ac.ftblDocDuLieuSP("thuan_qtdanhmucnguoidungloadcombochucvu", null);
        }
        public DataTable loadcombophongban()
        {
            return ac.ftblDocDuLieuSP("thuan_qtdanhmucnguoidungloadcombophongban", null);
        }
    }
}
